﻿@using CultureHelper = Mt.Site.Core.Localization.CultureHelper
@using Abp.Extensions
@{
    Layout = "";
}
<!DOCTYPE html>
<html>
<head>
    <title>打印预览</title>
    <meta charset="utf-8">
    <app-bundle asp-bundle-name="/content/build/Mt.oa.css"></app-bundle>
    <app-bundle asp-bundle-name="/content/build/Mt.lib.css" asp-is-rtl="CultureHelper.IsRtl"></app-bundle>
    <!--[if lt IE 9]>
        <script src="~/libs/respond/respond.min.js"></script>
        <script src="~/libs/html5shiv/html5shiv.js"></script>
        <script src="~/libs/excanvas/excanvas.min.js"></script>
    <![endif]-->
    <app-bundle asp-bundle-name="/content/build/Mt.lib.js"></app-bundle>
    <script type="text/javascript">
        var appModule = angular.module('app', [
            "ui.router",
            "ui.bootstrap",
            'ui.utils',
            "ui.jq",
            'ui.grid',
            'ui.grid.pagination',
            'ui.grid.treeView',
            'ui.grid.selection',
            'ui.grid.draggable-rows',
            'ui.grid.edit',
            "oc.lazyLoad",
            "ngSanitize",
            'angularFileUpload',
            'daterangepicker',
            'angularMoment',
            'frapontillo.bootstrap-switch',
            'abp',
            'ngFileUpload',
            'ng-pagination',
            'ngMap'
        ]).config(['$compileProvider', function ($compileProvider) {
            angular.lowercase = angular.$$lowercase;
            angular.uppercase = angular.$$uppercase;
            $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|itms\-apps|ftp|mailto|javascript):/);
        }]);
    </script>
    <script src="/AbpScripts/GetScripts?minify=true" type="text/javascript"></script>
    <script src="/AbpServiceProxies/GetAll?type=angularjs&v=@(DateTime.Now.Ticks)"></script>

    <app-bundle asp-bundle-name="/content/build/common.js"></app-bundle>
    <app-bundle asp-bundle-name="/content/build/Mt.js"></app-bundle>
    <app-bundle asp-bundle-name="/content/build/Mt.oa.js"></app-bundle>
</head>
<body style="overflow-y:scroll" class="page-print">
    <div ng-app="app">
        <div class="wrapper page-print" id="wrapper" ng-controller="myCtrl as vm">
            <!-- 表单 start -->
            <div class="form-box frm-gwcld frm-gwbj" style="padding: 50px 0 80px;">
                <div class="w954" style="width:700pt;margin-left: 50pt;">
                    <table class="table-gwbj gwbjDet" style="width:100%;border-collapse:collapse; border:none; font-family:仿宋_GB2312; font-size:12pt;color: #000;line-height: 18pt;">
                        <thead>
                            <tr>
                                <td colspan="6" style="border: none;text-align:center;font-size:33pt;line-height:45pt;font-weight: bold;font-family:楷体_GB2312;color: #ff0000;padding:0;margin:0pt 0pt 0.0001pt;">市运河集团公文处理单（办件）</td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr style="page-break-inside:avoid" class="tr1">
                                <td colspan="6" style="border:none;border-bottom:1.0000pt solid #ff0000; width:477.4pt; padding:40pt 2.85pt 5.65pt 2.85pt; font-family:仿宋_GB2312;" valign="bottom" width="636">
                                    <div style="width: 100%;display: table;">
                                        <div class="td-mj" style="width:30%;display: table-cell;vertical-align: middle;white-space: nowrap;"><span style="color: #ff0000;">密级：&nbsp;</span><span>{{vm.data.mijicd}}</span></div>
                                        <div class="td-zmcd" style="width:30%;display: table-cell;vertical-align: middle;white-space: nowrap;text-align: left;">
                                            <span style="color: #ff0000;">紧急程度：</span>
                                            <span>{{vm.data.jinjicd}}</span>
                                        </div>
                                        <div class="td-swbh" style="width:40%;display: table-cell;vertical-align: middle;white-space: nowrap;text-align: right;">
                                            <span style="color: #ff0000;">收文编号：</span><span>{{vm.data.bianhao}}</span>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr style="height:24.1000pt; page-break-inside:avoid" class="tr2">
                                <td class="td1" style="border:1.0000pt solid #ff0000; width:66.6500pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt;color:#ff0000;white-space: nowrap;text-align: center;" valign="middle" width="88">来文单位</td>
                                <td class="td2" style="border:1.0000pt solid #ff0000; width:92.1500pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ; " valign="middle" width="122">{{vm.data.lwdw}}</td>
                                <td class="td3" style="border:1.0000pt solid #ff0000; width:63.8000pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt; color:#ff0000;white-space: nowrap;text-align: center;" valign="middle" width="85">收文日期</td>
                                <td class="td4" style="border:1.0000pt solid #ff0000; width:85.0500pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt;" valign="middle" width="113">{{vm.getDateTimeFromUnix(vm.data.swrq)}}</td>
                                <td class="td5" style="border:1.0000pt solid #ff0000; width:84.8500pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ; color:#ff0000;white-space: nowrap;text-align: center;" valign="middle" width="113">办理期限</td>
                                <td class="td6" style="border:1.0000pt solid #ff0000; width:84.9000pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ;" valign="middle" width="113">{{vm.getDateTimeFromUnix(vm.data.banliqx)}}</td>
                            </tr>
                            <tr class="tr3" style="height:24.1000pt; page-break-inside:avoid">
                                <td style="border:1.0000pt solid #ff0000; width:66.6500pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ; color:#ff0000;text-align: center;" valign="middle" width="88">
                                    <div>来文标题</div>
                                    <div>（字 号）</div>
                                </td>
                                <td colspan="5" style="border:1.0000pt solid #ff0000; width:410.7500pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ;" valign="middle" width="547">{{vm.data.lwbt}}</td>
                            </tr>
                            <tr class="tr4" style="page-break-inside:avoid">
                                <td style="border:1.0000pt solid #ff0000; width:66.6500pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ; color:#ff0000;text-align: center;" valign="middle" width="88">领导批示</td>
                                <td colspan="5" style="border:1.0000pt solid #ff0000; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ;" valign="top">
                                    <ul class="resultList">
                                        <li style="overflow: hidden;" ng-repeat="x in vm.replyRemarkData.ldpsYj">
                                            <div class="doc fl">{{x.reply}}</div>
                                            <div class="info fr">
                                                <span class="time" style="float: right;margin-left:10px;">{{vm.getReplyTimeFormat(x.replyTime)}}</span>
                                                <span class="name fl" style="float: right;min-width: 3em;color:#000;">{{x.userName}}</span>
                                            </div>
                                        </li>
                                    </ul>
                                </td>
                            </tr>
                            <tr class="tr5" style="page-break-inside:avoid">
                                <td style="border:1.0000pt solid #ff0000; padding:5.6500pt 2.8500pt; color:#ff0000;text-align: center; white-space: nowrap;" valign="middle" width="88"><div>办理（会办）</div><div>意见</div></td>
                                <td colspan="5" style="border:1.0000pt solid #ff0000; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ;" valign="top">
                                    <ul class="resultList">
                                        <li style="overflow: hidden;" ng-repeat="x in vm.replyRemarkData.blYj">
                                            <div class="doc fl" style="text-indent: {{x.isLeader? 2:0}}em;">{{x.reply}}</div>
                                            <div class="info fr" style="padding-right: {{x.isLeader? 0:2}}em;">
                                                <span class="time" style="float: right;margin-left:10px;">{{vm.getReplyTimeFormat(x.replyTime)}}</span>
                                                <span class="name fl" style="float: right;min-width: 3em;color:#000;">{{x.userName}}</span>
                                            </div>
                                        </li>

                                    </ul>
                                </td>
                            </tr>
                            <tr class="tr6" style="page-break-inside:avoid">
                                <td style="border:1.0000pt solid #ff0000; padding:5.6500pt 2.8500pt; color:#ff0000;text-align: center; white-space: nowrap;" valign="middle" width="88">分办意见</td>
                                <td colspan="5" style="border:1.0000pt solid #ff0000; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ;" valign="top">
                                    <ul class="resultList">
                                        <li style="overflow: hidden;" ng-repeat="x in vm.replyRemarkData.fbYj">
                                            <div class="doc fl" style="text-indent: {{x.isLeader? 2:0}}em;">{{x.reply}}</div>
                                            <div class="info fr" style="padding-right: {{x.isLeader? 0:2}}em;">
                                                <span class="time" style="float: right;margin-left:10px;">{{vm.getReplyTimeFormat(x.replyTime)}}</span>
                                                <span class="name fl" style="float: right;min-width: 3em;color:#000;">{{x.userName}}</span>
                                            </div>
                                        </li>
                                    </ul>
                                </td>
                            </tr>
                            <tr class="tr7" style="page-break-inside:avoid">
                                <td style="border:1.0000pt solid #ff0000; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ; color:#ff0000;text-align: center;" valign="middle" width="88">办理结果</td>
                                <td colspan="5" style="border:1.0000pt solid #ff0000; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ;" valign="top">
                                    <ul class="resultList">
                                        <li style="overflow: hidden;" ng-repeat="x in vm.replyRemarkData.bljgYj">
                                            <div class="doc fl">{{x.reply}}</div>
                                            <div class="info fr" style="padding-right: 2em;">
                                                <span class="time" style="float: right;margin-left:10px;">{{vm.getReplyTimeFormat(x.replyTime)}}</span>
                                                <span class="name fl" style="float: right;min-width: 3em;color:#000;">{{x.userName}}</span>
                                            </div>
                                        </li>
                                    </ul>
                                </td>
                            </tr>
                            <tr class="tr8" style="height:30.7500pt; page-break-inside:avoid">
                                <td style="border:1.0000pt solid #ff0000; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ; color:#ff0000;text-align: center;" valign="middle" width="88">归　　档</td>
                                <td colspan="5" style="border:1.0000pt solid #ff0000; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ;" valign="top">
                                    <ul class="resultList">
                                        <li style="overflow: hidden" ng-repeat="x in vm.replyRemarkData.gdYj">
                                            <div class="doc fl">{{x.reply}}</div>
                                            <div class="info fr" style="padding-right: 2em;">
                                                <span class="time" style="float: right;margin-left:10px;">{{vm.getReplyTimeFormat(x.replyTime)}}</span>
                                                <span class="name fl" style="float: right;min-width: 3em;color:#000;">{{x.userName}}</span>
                                            </div>
                                        </li>
                                    </ul>
                                </td>
                            </tr>
                            <tr class="tr9" style="height:24.1000pt; page-break-inside:avoid">
                                <td style="border:1.0000pt solid #ff0000; width:66.6500pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ; color:#ff0000;text-align: center;" valign="middle" width="88">备　　注</td>
                                <td colspan="5" style="border:1.0000pt solid #ff0000; width:410.7500pt; padding:5.6500pt 2.8500pt 5.6500pt 2.8500pt ;" valign="middle" width="547">
                                    <span ng-bind-html="vm.data.beizhu"></span>
                                </td>
                            </tr>
                            <tr class="tr10">
                                <td colspan="6" style="border:none; padding:0 2.8500pt;" valign="middle">
                                    <div style="overflow: hidden; position: relative;">
                                        <div class="tit fl" style="margin-right: 10px;font-weight: bold;">附件：</div>
                                    </div>
                                    <ul class="attach-list" style="margin: 0;">
                                        <li style="width: 100%;overflow: hidden;" ng-repeat="file in vm.fileAttachs">
                                            <a class="tit fl" href="javascript:void(0)" title="{{file.fileName}}" style="margin-right: 30px;color:#000;">{{file.fileName}}</a>
                                            <div class="info fl"><span style="margin-right: 10px">{{file.userName}}</span><span>{{vm.getReplyTimeFormat(file.creationTime)}}</span></div>
                                        </li>
                                    </ul>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- 表单 end -->

            <div class="editTxt-ft" ng-if="vm.toolbarShow" style="margin-bottom:10px;">
                <ul class="tool-box fl">
                    <li>
                        <a href="javascript:void(0)" ng-click="vm.print()"><img src="/content/images_N/icon_print.png" />打印表单</a>
                    </li>
                </ul>
                <div class="btn-box fr" ng-show="false">
                    <label for="ck1"><input type="checkbox" ng-checked="vm.formCk" ng-click="vm.formCk=!vm.formCk" id="ck1" /> &nbsp;表单</label>
                    &nbsp;&nbsp;&nbsp;<label ng-if="vm.workFlowData.isHaveOnlineWord" for="ck2"><input type="checkbox" ng-checked="vm.onlineWord" ng-click="vm.onlineWord=!vm.onlineWord" id="ck2" /> &nbsp;在线word</label>
                    &nbsp;&nbsp;&nbsp;<label for="ck4"><input type="checkbox" ng-checked="vm.opinion" ng-click="vm.opinion=!vm.opinion" id="ck4" /> &nbsp;轨迹</label>
                    &nbsp;&nbsp;&nbsp;<label for="ck5"><input type="checkbox" ng-checked="vm.logs" ng-click="vm.logs=!vm.logs" id="ck5" /> &nbsp;日志</label>
                    &nbsp;&nbsp;&nbsp;<label for="ck3"><input type="checkbox" ng-checked="vm.fujian" ng-click="vm.fujian=!vm.fujian" id="ck3" /> &nbsp;附件</label>
                    &nbsp;&nbsp;&nbsp;<label for="ck3"><input type="checkbox" ng-checked="vm.cuiBanjiLu" ng-click="vm.cuiBanjiLu=!vm.cuiBanjiLu" id="ck3" /> &nbsp;催办记录</label>
                    &nbsp;&nbsp;&nbsp;<label for="ck3"><input type="checkbox" ng-checked="vm.cuiYuejiLu" ng-click="vm.cuiYuejiLu=!vm.cuiYuejiLu" id="ck3" /> &nbsp;催阅记录</label>
                </div>
            </div>
        </div>
    </div>
    
    <script type="text/javascript">
        appModule.controller('myCtrl', ['$scope', 'abp.services.app.archive', 'abp.services.app.workFlow', '$compile', 'appHttpUtilityHelper', 'workflowHelper'
            , 'abp.services.app.mtNotification', 'abp.services.app.workFlowFileUpload',
                function ($scope, archiveService, workFlowService, $compile, appHttpUtilityHelper, workflowHelper, mtNotificationService,workFlowFileUpload) {
                    var vm = this;
                    vm.paperId = '@ViewBag.paperId';
                    vm.archived =@(ViewBag.archived == 1?"true":"false");

                    vm.workFlowData = {};
                    vm.remarkData = [];         //流程轨迹
                    vm.passRoundData = [];      //传阅记录
                    vm.data = {};               //表单字段数据
                    vm.fieldDisabled = {};      //表单字段是否可编辑
                    vm.canEditAttach = false;
                    vm.paperState = -1;
                    vm.isTitleEdit = false;
                    vm.toolbarShow = true;

                    vm.formCk = true;
                    vm.onlineWord = false;
                    vm.fujian = false;
                    vm.cuiBanjiLu = false;
                    vm.cuiYuejiLu = false;
                    vm.opinion = false;
                    vm.logs = false;
                    vm.wfUniqueName = {
                        bj: '收文办件',
                        yj: '收文阅件',
                        yglh: '因公离杭'
                    };
                    var serviceName = workFlowService.getDataForPrint;
                    if (vm.archived) {
                        serviceName = archiveService.getDataForPrint;
                    }

                    vm.replyRemarkData = {
                        ldpsYj: [],
                        blYj: [],
                        fbYj: [],
                        bljgYj: [],
                        gdYj:[]
                    }

                    vm.getReplyMsg = function () {
                        vm.replyRemarkData.ldpsYj = vm.getLeaderpsyj('34a10933-073a-4451-34f2-08d843445b78', 'c5794db5-645a-445a-34f1-08d843445b78');
                        vm.replyRemarkData.blYj = vm.getFbjgRemarkData('34a10933-073a-4451-34f2-08d843445b78');
                        vm.replyRemarkData.fbYj = vm.getFbyjRemarkData('b037d8ff-b121-47be-34ef-08d843445b78,dfe9e28f-1bd6-4ab1-34f0-08d843445b78,c5794db5-645a-445a-34f1-08d843445b78');
                        vm.replyRemarkData.bljgYj = vm.getRemarkDataInfo('40654a71-3978-492c-34f3-08d843445b78');
                        vm.replyRemarkData.gdYj = vm.getRemarkDataInfo('dfd4aa1b-3d56-427d-34f4-08d843445b78');
                    }

                    vm.getFlowWorkData = function () {
                        if (vm.paperId) {
                            serviceName({ paperId: vm.paperId }).then(function (result) {
                                vm.workFlowData = result.data;
                                vm.paperState = vm.workFlowData.paperState;
                                vm.canEditAttach = vm.workFlowData.canEditAttachment;
                                vm.data = result.data.formData.data;
                                vm.remarkData = workflowHelper.getRemarkData(vm.workFlowData.remarkData);
                                vm.passRoundData = workflowHelper.getPassRoundData(vm.workFlowData.remarkData);

                                //loadNoticeList();
                                getFileAttachs(vm.workFlowData.paper.id);

                                vm.getReplyMsg();
                                setTimeout(function () {
                                    $("#formdata :text,textarea").each(function () {
                                        var val = $(this).val();
                                        $(this).parent().css("text-align", "left");
                                        $(this).hide().after("<span>" + val + "</span>");
                                    });
                                    //隐藏按钮
                                    $("#formdata button").hide();
                                    $("#formdata input[type='checkbox']").css("-webkit-appearance", "checkbox");
                                    $("#formdata input[type='radio']").css("-webkit-appearance", "radio");
                                }, 800);
                            });
                        }
                    };

                    vm.getFlowWorkData();

                    vm.checkState = function (data) {
                        return workflowHelper.checkState(data);
                    };

                    vm.timeFormat = function (time) {
                        return workflowHelper.timeFormat(time);
                    };

                    vm.timeDiffCalc = function (state, markTime, finishedTime) {
                        return workflowHelper.timeDiffCalc(state, markTime, finishedTime);
                    };

                    vm.getDateTimeFromUnix = function (unixTime) {
                        if (unixTime) {
                            return moment(parseInt(unixTime)).format('YYYY-MM-DD');
                        }
                        return '';
                    }

                    vm.fileAttachs = [];
                    function getFileAttachs(paperId) {
                        vm.loading = true;
                        workFlowFileUpload.getWorkFlowFiles({ id: paperId }).then(function (result) {
                            vm.fileAttachs = result.data;
                        }).finally(function () {
                            vm.loading = false;
                        });
                    }

                    vm.print = function () {
                        vm.toolbarShow = false;
                        setTimeout(function () {
                            window.focus();
                            window.print();
                            window.close();
                        }, 300);
                    };

                    vm.getReplyTimeFormat = function (time) {
                        if (!time) return '';
                        return moment(time).format("YYYY-MM-DD HH:mm")
                    }

                    /// 环节nodeIds，职务排序orderByzw
                    vm.getRemarkDataInfo = function (nodeIds, orderByzw) {
                        if (!nodeIds) return [];
                        if (!vm.workFlowData.remarkData) return [];
                        var datas = JSON.parse(JSON.stringify(vm.workFlowData.remarkData));
                        if (orderByzw) {
                            datas.sort((a, b) => { b.userInfo.order - a.userInfo.order });
                        }
                        var newRemarkData = [];
                        angular.forEach(datas, function (value) {
                            if (nodeIds.indexOf(value.nodeId) > -1 && value.reply
                                && value.operationType == 1 && value.signal2 != 'DisplayInHuiBan') { // 办理
                                newRemarkData.push(value);
                            }
                        });
                        return newRemarkData;
                    }

                    vm.getFbjgRemarkData = function (nodeIds) {
                        if (!nodeIds) return [];
                        if (!vm.workFlowData.remarkData) return [];
                        var datas = JSON.parse(JSON.stringify(vm.workFlowData.remarkData));
                        return workflowHelper.getDealWithData(datas, vm.workFlowData.relationships, vm.workFlowData.additionalMsg, nodeIds);
                    }

                    /// 领导批示件
                    vm.getLeaderpsyj = function (nodeId, qyNodeId) {
                        var remartDataInfo = [];
                        if (!vm.workFlowData.remarkData) return [];
                        var datas = JSON.parse(JSON.stringify(vm.workFlowData.remarkData));
                        datas.sort((a, b) => { b.userInfo.order - a.userInfo.order });
                        for (var i = 0, len = datas.length; i < len; i++) {
                            var item = datas[i];
                            if (!item.reply) continue;
                            if (qyNodeId.indexOf(item.nodeId) > -1) {
                                remartDataInfo.push(item);
                            }
                            else if (nodeId &&
                                nodeId.indexOf(item.nodeId) > -1
                                && item.operationType == 0) {
                                remartDataInfo.push(item);
                            }
                        }
                        return remartDataInfo;
                    }

                    // 分办意见
                    vm.getFbyjRemarkData = function (nodeIds) {
                        var remartDataInfo = [];
                        if (!vm.workFlowData.remarkData) return [];
                        var datas = JSON.parse(JSON.stringify(vm.workFlowData.remarkData));

                        for (var i = 0, len = datas.length; i < len; i++) {
                            var item = datas[i];
                            if (nodeIds && nodeIds.indexOf(item.nodeId) > -1
                                && item.finishedTime) {
                                if (item.customData) {
                                    var newCustomData = JSON.parse(item.customData);
                                    item.reply = newCustomData.Msg;
                                    item.isLeader = true;
                                }
                                if (!item.reply) continue;
                                remartDataInfo.push(item);
                            }
                        }
                        remartDataInfo.sort((a, b) => Date.parse(a.finishedTime) - Date.parse(b.finishedTime))//时间正序)
                        return remartDataInfo;
                    }
                }
            ]);
    </script>
</body>
</html>

